<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ include file="/WEB-INF/jsp/commons/taglibs.jsp"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>E-天下商旅</title>
<link href="${ctx}/resources/css/jbox_skin_blue/jbox.css" rel="stylesheet" type="text/css">
<link href="${ctx}/resources/css/page_member.css" rel="stylesheet" type="text/css">

</head>

<body>

<jsp:include page="../commons/header.jsp" >
     <jsp:param name="currentMenu" value="menu3"/>
</jsp:include>

<div class="main_box">
<div class="main cf">

	<jsp:include page="../commons/left.jsp"></jsp:include>
		<div class="right">
		<div class="right_box">
			<div class="title"><span><a href="#">激活会员</a></span></div>
			<div class="content cf">
				<div class="activat_box">
					<img class="top_img" src="${ctx}/resources/img/top2.png">
					<div class="activat_bottom">
						<div class="activat_bottom_title cf"><a href="#" id="js_tab1" class="first current">激活会员</a><a href="#" id="js_tab2" class="second">激活列表</a></div>
						<div id="js_tab_box1">
							<form action="${ctx}/memberBI/activeMember" onsubmit="">
								<div>
									<label>账户余额</label>
									<fmt:formatNumber value="${memberWallet.walletRemain}" pattern="##.##" minFractionDigits="2" ></fmt:formatNumber>元
								</div>
								<div>
									<label>被激活会员的账户</label>
									<input type="text" class="input" name="activeName" id="activeName" ><span></span>
								</div>
								<div>
									<label></label>
									<a href="#" id="js_choose_a" title="验证激活会员">验证</a><span id="js_choose_c"></span>
								</div>
								<div>
									<label><i>* </i>加盟等级</label>
									<input id="grade1" type="radio" checked="checked" value="1" name="grade"><label class="label" for="grade1">铜旅<img src="${ctx}/resources/img/grade1.png"></label>
									<input id="grade2" type="radio" value="2" name="grade"><label class="label" for="grade2">银旅<img src="${ctx}/resources/img/grade2.png"></label>
									<input id="grade3" type="radio" value="5" name="grade"><label class="label" for="grade3">金旅<img src="${ctx}/resources/img/grade3.png"></label>
									<input id="grade4" type="radio" value="10" name="grade"><label class="label" for="grade4">VIP旅<img src="${ctx}/resources/img/grade4.png"></label>
									<input id="grade5" type="radio" value="30" name="grade"><label class="label" for="grade5">VIP钻石旅<img src="${ctx}/resources/img/grade5.png"></label>
								</div>
								<div>
									<label>&nbsp;</label>
									<input type="submit" class="submit btn_orange" value="立即激活" />
								</div>
							</form>
						</div>
						<div id="js_tab_box2">
							<table id="table" class="table center">
								<thead>
									<tr>
										<th width="60">激活用户名</th>
										<th width="90">激活类型</th>
										<th width="90">激活时间</th>
									</tr>
								</thead>
								<tbody>
							     <c:forEach var="active" items="${activeList}">
									<tr>
										<td>${active.activeName }</td>
										<td>
										<c:if test="${active.activeType == 1}">铜旅<img src="${ctx}/resources/img/grade1.png"></c:if>
										<c:if test="${active.activeType == 2}">银旅<img src="${ctx}/resources/img/grade2.png"></c:if>
										<c:if test="${active.activeType == 5}">金旅<img src="${ctx}/resources/img/grade3.png"></c:if>
										<c:if test="${active.activeType == 10}">VIP旅<img src="${ctx}/resources/img/grade4.png"></c:if>
										<c:if test="${active.activeType == 30}">VIP钻石旅<img src="${ctx}/resources/img/grade5.png"></c:if>
										</td>
										<td><fmt:formatDate value="${active.activeTime}" pattern="yyyy-MM-dd" /></td>
									</tr>
								</c:forEach>	
								</tbody>
							</table>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
		
</div>
</div>

<jsp:include page="../commons/footer.jsp"></jsp:include>

<script src="${ctx}/resources/script/validate/jquery-1.4.min.js" type="text/javascript"></script>
<script src="${ctx}/resources/script/common.js"></script>
<script src="${ctx}/resources/script/jquery.jBox-2.3.min.js"></script>
<script src="${ctx}/resources/script/jquery.jBox-zh-CN.js"></script> 
<script type="text/javascript" src="${ctx}/resources/script/validate/jquery.validate.js"></script>
<script type="text/javascript" src="${ctx}/resources/script/validate/jquery.metadata.js"></script>
<script type="text/javascript" src="${ctx}/resources/script/validate/additional-methods.js" charset="utf-8"></script>
<script type="text/javascript" src="${ctx}/resources/script/validate/messages_cn.js" charset="utf-8"></script>
<script>
$.validator.setDefaults({
	submitHandler: function() { ajaxActivation(); }
 });
 
 function ajaxActivation(){
		var url = "${ctx}/memberBI/activeMember";
	    $.ajax({
	        type: "post",
	        async:false,
	        url: url,
	        dataType: "json",
	        data:$("form").serialize(),
	        success: function(getmsg){  
	            if(getmsg.code==0) {
	        		//$.jBox(getmsg.context, {
	        		//	title: "提示消息",
	        		//	bottomText: ""
	        		//});
	        		alert(getmsg.context);
	            } 
	            else
	            {
	        		//$.jBox("注册成功", {
	        		//	title: "提示消息",
	        		//	bottomText: ""
	        		//});
	        		alert("激活成功");
	        		window.location.href="${ctx}/memberBI/activeMemberIndex";
	            }
	        }
	    });
 }

$(function() {			
	$("form").validate({
		rules : {
			activeName:{
				required : true,
				remote:{
					url: "${ctx}/memberBI/checkActiveMember", //后台处理程序    
			        type:"post",
			        dataType: "json",       				 //接受数据格式      
			        data:  {                     			 //要传递的数据   
			        	activeName: function() {   
			        				return $("#activeName").val();   
			        	  		  }		  
			        } 
				}
			}
		},
		errorPlacement : function(error, element) {
			error.appendTo(element.next("span"));
		},
		messages : {
			activeName:{
				requried:"请输入会员账号",
				remote:"该会员不存在，或已被激活"
			}
		}
	 });
});	  

$("#js_choose_a").click(function(e){
	var url = "${ctx}/memberBI/checkUserAccount?timestap="+(new Date()).valueOf();		
     $.ajax({
         type: "post",
         async:false,
         url: url,
         dataType: "json",
         data:$("#activeName").serialize(),
         success: function(getmsg){  	        	 
        	 $("#js_choose_c").text(getmsg);
         	         	 
         }
     });
});
</script>
</body>
</html>

